$(document).ready(function(e) {
	$('#confirm_chckbox').click(function () {
		if($('#confirm_chckbox').is(':checked')){
			$('#confirm').removeAttr('disabled');
		}
		else {
			$('#confirm').attr('disabled', 'disabled');
		}
	});
	
	$('input[name="not_applicable"]').click(function (){
		var target = $(this).val();
		if($(this).is(':checked')){
			$('input[name="'+target+'"]').val('N/A');
		}
		else {
			$('input[name="'+target+'"]').val('');
		}
	});
	
	if($("#dob").is(':visible')){
		$('#dob').datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange: '1970:2000',
			dateFormat: 'MM dd, yy'
		});
	}
	
	$('.enable-edit').click(function (){
		var target = '.'+$(this).val();
		if($(this).is(':checked')){
			$('.submit').removeClass('hidden-btn')
			$(target).removeClass('disabled');
			$(target).removeAttr('disabled');
		}
		else {
			$('.submit').addClass('hidden-btn');
			$(target).addClass('disabled');
			$(target).attr('disabled', 'disabled');
		}
	})

});


/*===================================Native Javascript Functions========================================================================*/
function open_url(url){
	var myWindow = window.open(url,'name','height=700,width=500');
	myWindow.focus();
}

function post_value(){
	var radio = getRadioCheckedValue('course');
	opener.document.frm_addstudent.course.value = radio[1];
	opener.document.frm_addstudent.course_code.value = radio[0];
	self.close();
}

function post_value_semester(){
	var radio = getRadioCheckedValue('semester_radio');

	opener.document.set_semster.current_semester.value = radio[0];
	opener.document.set_semster.semester_id.value = radio[1];
	self.close();

}

function getRadioCheckedValue(radio_name)
{
   var oRadio = document.forms[0].elements[radio_name];
	if(oRadio.length != null){
	   for(var i = 0; i < oRadio.length; i++)
	   {
		  if(oRadio[i].checked)
		  {
			 var myRadio=new Array(oRadio[i].value,oRadio[i].id);
		     return myRadio;
		  }
	   }
	}
	else {
		var myRadio = new Array(oRadio.value, oRadio.id);	
		return myRadio;
	}
   return '';
	
}

function delete_item(it){
	var x;
	var r=confirm("Delete "+it);
	if (r==true)
  	{
  		return true;
  	}
	else
  	{
		return false;
  	}
}